<?php
declare(strict_types=1);

namespace App\Jobs\RoomPK;


use App\Jobs\Job;
use App\Repositories\RoomPk\RoomPKInviteRepository;
use App\Repositories\RoomPk\RoomPKRepository;

class PKInviteTimeoutJob extends Job
{
    public $inviteId;

    public function __construct(int $inviteId)
    {
        $this->inviteId = $inviteId;
    }

    public function handle()
    {
        try{
            RoomPKInviteRepository::getInstance()->timeout($this->inviteId);
        }catch (\Exception $e){
            file_put_contents(
                storage_path() . '/logs/pk-job-' . date('Ymd') . '.log',
                "name: InviteTimeoutJob, message: {$e->getMessage()}, line: {$e->getLine()}, file: {$e->getFile()}" . PHP_EOL, FILE_APPEND
            );
        }
    }
}